home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / src / linux-headers-2.6.28-15 / arch / sparc / include / asm / oplib_32.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-12-24  |  8.7 KB  |  272 lines

  1. /*
  2.  * oplib.h:  Describes the interface and available routines in the
  3.  *           Linux Prom library.
  4.  *
  5.  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6.  */
  7.  
  8. #ifndef __SPARC_OPLIB_H
  9. #define __SPARC_OPLIB_H
  10.  
  11. #include <asm/openprom.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/compiler.h>
  14.  
  15. /* The master romvec pointer... */
  16. extern struct linux_romvec *romvec;
  17.  
  18. /* Enumeration to describe the prom major version we have detected. */
  19. enum prom_major_version {
  20.     PROM_V0,      /* Original sun4c V0 prom */
  21.     PROM_V2,      /* sun4c and early sun4m V2 prom */
  22.     PROM_V3,      /* sun4m and later, up to sun4d/sun4e machines V3 */
  23.     PROM_P1275,   /* IEEE compliant ISA based Sun PROM, only sun4u */
  24. };
  25.  
  26. extern enum prom_major_version prom_vers;
  27. /* Revision, and firmware revision. */
  28. extern unsigned int prom_rev, prom_prev;
  29.  
  30. /* Root node of the prom device tree, this stays constant after
  31.  * initialization is complete.
  32.  */
  33. extern int prom_root_node;
  34.  
  35. /* Pointer to prom structure containing the device tree traversal
  36.  * and usage utility functions.  Only prom-lib should use these,
  37.  * users use the interface defined by the library only!
  38.  */
  39. extern struct linux_nodeops *prom_nodeops;
  40.  
  41. /* The functions... */
  42.  
  43. /* You must call prom_init() before using any of the library services,
  44.  * preferably as early as possible.  Pass it the romvec pointer.
  45.  */
  46. extern void prom_init(struct linux_romvec *rom_ptr);
  47.  
  48. /* Boot argument acquisition, returns the boot command line string. */
  49. extern char *prom_getbootargs(void);
  50.  
  51. /* Device utilities. */
  52.  
  53. /* Map and unmap devices in IO space at virtual addresses. Note that the
  54.  * virtual address you pass is a request and the prom may put your mappings
  55.  * somewhere else, so check your return value as that is where your new
  56.  * mappings really are!
  57.  *
  58.  * Another note, these are only available on V2 or higher proms!
  59.  */
  60. extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);
  61. extern void prom_unmapio(char *virt_addr, unsigned int num_bytes);
  62.  
  63. /* Device operations. */
  64.  
  65. /* Open the device described by the passed string.  Note, that the format
  66.  * of the string is different on V0 vs. V2->higher proms.  The caller must
  67.  * know what he/she is doing!  Returns the device descriptor, an int.
  68.  */
  69. extern int prom_devopen(char *device_string);
  70.  
  71. /* Close a previously opened device described by the passed integer
  72.  * descriptor.
  73.  */
  74. extern int prom_devclose(int device_handle);
  75.  
  76. /* Do a seek operation on the device described by the passed integer
  77.  * descriptor.
  78.  */
  79. extern void prom_seek(int device_handle, unsigned int seek_hival,
  80.               unsigned int seek_lowval);
  81.  
  82. /* Miscellaneous routines, don't really fit in any category per se. */
  83.  
  84. /* Reboot the machine with the command line passed. */
  85. extern void prom_reboot(char *boot_command);
  86.  
  87. /* Evaluate the forth string passed. */
  88. extern void prom_feval(char *forth_string);
  89.  
  90. /* Enter the prom, with possibility of continuation with the 'go'
  91.  * command in newer proms.
  92.  */
  93. extern void prom_cmdline(void);
  94.  
  95. /* Enter the prom, with no chance of continuation for the stand-alone
  96.  * which calls this.
  97.  */
  98. extern void prom_halt(void) __attribute__ ((noreturn));
  99.  
  100. /* Set the PROM 'sync' callback function to the passed function pointer.
  101.  * When the user gives the 'sync' command at the prom prompt while the
  102.  * kernel is still active, the prom will call this routine.
  103.  *
  104.  * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
  105.  */
  106. typedef void (*sync_func_t)(void);
  107. extern void prom_setsync(sync_func_t func_ptr);
  108.  
  109. /* Acquire the IDPROM of the root node in the prom device tree.  This
  110.  * gets passed a buffer where you would like it stuffed.  The return value
  111.  * is the format type of this idprom or 0xff on error.
  112.  */
  113. extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
  114.  
  115. /* Get the prom major version. */
  116. extern int prom_version(void);
  117.  
  118. /* Get the prom plugin revision. */
  119. extern int prom_getrev(void);
  120.  
  121. /* Get the prom firmware revision. */
  122. extern int prom_getprev(void);
  123.  
  124. /* Character operations to/from the console.... */
  125.  
  126. /* Non-blocking get character from console. */
  127. extern int prom_nbgetchar(void);
  128.  
  129. /* Non-blocking put character to console. */
  130. extern int prom_nbputchar(char character);
  131.  
  132. /* Blocking get character from console. */
  133. extern char prom_getchar(void);
  134.  
  135. /* Blocking put character to console. */
  136. extern void prom_putchar(char character);
  137.  
  138. /* Prom's internal routines, don't use in kernel/boot code. */
  139. extern void prom_printf(char *fmt, ...);
  140. extern void prom_write(const char *buf, unsigned int len);
  141.  
  142. /* Multiprocessor operations... */
  143.  
  144. /* Start the CPU with the given device tree node, context table, and context
  145.  * at the passed program counter.
  146.  */
  147. extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
  148.              int context, char *program_counter);
  149.  
  150. /* Stop the CPU with the passed device tree node. */
  151. extern int prom_stopcpu(int cpunode);
  152.  
  153. /* Idle the CPU with the passed device tree node. */
  154. extern int prom_idlecpu(int cpunode);
  155.  
  156. /* Re-Start the CPU with the passed device tree node. */
  157. extern int prom_restartcpu(int cpunode);
  158.  
  159. /* PROM memory allocation facilities... */
  160.  
  161. /* Allocated at possibly the given virtual address a chunk of the
  162.  * indicated size.
  163.  */
  164. extern char *prom_alloc(char *virt_hint, unsigned int size);
  165.  
  166. /* Free a previously allocated chunk. */
  167. extern void prom_free(char *virt_addr, unsigned int size);
  168.  
  169. /* Sun4/sun4c specific memory-management startup hook. */
  170.  
  171. /* Map the passed segment in the given context at the passed
  172.  * virtual address.
  173.  */
  174. extern void prom_putsegment(int context, unsigned long virt_addr,
  175.                 int physical_segment);
  176.  
  177.  
  178. /* PROM device tree traversal functions... */
  179.  
  180. #ifdef PROMLIB_INTERNAL
  181.  
  182. /* Internal version of prom_getchild. */
  183. extern int __prom_getchild(int parent_node);
  184.  
  185. /* Internal version of prom_getsibling. */
  186. extern int __prom_getsibling(int node);
  187.  
  188. #endif
  189.  
  190.  
  191. /* Get the child node of the given node, or zero if no child exists. */
  192. extern int prom_getchild(int parent_node);
  193.  
  194. /* Get the next sibling node of the given node, or zero if no further
  195.  * siblings exist.
  196.  */
  197. extern int prom_getsibling(int node);
  198.  
  199. /* Get the length, at the passed node, of the given property type.
  200.  * Returns -1 on error (ie. no such property at this node).
  201.  */
  202. extern int prom_getproplen(int thisnode, char *property);
  203.  
  204. /* Fetch the requested property using the given buffer.  Returns
  205.  * the number of bytes the prom put into your buffer or -1 on error.
  206.  */
  207. extern int __must_check prom_getproperty(int thisnode, char *property,
  208.                      char *prop_buffer, int propbuf_size);
  209.  
  210. /* Acquire an integer property. */
  211. extern int prom_getint(int node, char *property);
  212.  
  213. /* Acquire an integer property, with a default value. */
  214. extern int prom_getintdefault(int node, char *property, int defval);
  215.  
  216. /* Acquire a boolean property, 0=FALSE 1=TRUE. */
  217. extern int prom_getbool(int node, char *prop);
  218.  
  219. /* Acquire a string property, null string on error. */
  220. extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
  221.  
  222. /* Does the passed node have the given "name"? YES=1 NO=0 */
  223. extern int prom_nodematch(int thisnode, char *name);
  224.  
  225. /* Search all siblings starting at the passed node for "name" matching
  226.  * the given string.  Returns the node on success, zero on failure.
  227.  */
  228. extern int prom_searchsiblings(int node_start, char *name);
  229.  
  230. /* Return the first property type, as a string, for the given node.
  231.  * Returns a null string on error.
  232.  */
  233. extern char *prom_firstprop(int node, char *buffer);
  234.  
  235. /* Returns the next property after the passed property for the given
  236.  * node.  Returns null string on failure.
  237.  */
  238. extern char *prom_nextprop(int node, char *prev_property, char *buffer);
  239.  
  240. /* Returns phandle of the path specified */
  241. extern int prom_finddevice(char *name);
  242.  
  243. /* Returns 1 if the specified node has given property. */
  244. extern int prom_node_has_property(int node, char *property);
  245.  
  246. /* Set the indicated property at the given node with the passed value.
  247.  * Returns the number of bytes of your value that the prom took.
  248.  */
  249. extern int prom_setprop(int node, char *prop_name, char *prop_value,
  250.             int value_size);
  251.  
  252. extern int prom_pathtoinode(char *path);
  253. extern int prom_inst2pkg(int);
  254.  
  255. /* Dorking with Bus ranges... */
  256.  
  257. /* Apply promlib probes OBIO ranges to registers. */
  258. extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
  259.  
  260. /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
  261. extern void prom_apply_generic_ranges(int node, int parent,
  262.                       struct linux_prom_registers *sbusregs, int nregs);
  263.  
  264. /* CPU probing helpers.  */
  265. int cpu_find_by_instance(int instance, int *prom_node, int *mid);
  266. int cpu_find_by_mid(int mid, int *prom_node);
  267. int cpu_get_hwmid(int prom_node);
  268.  
  269. extern spinlock_t prom_lock;
  270.  
  271. #endif /* !(__SPARC_OPLIB_H) */
  272.